﻿using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using Rhino.Mocks;

namespace TSVNAddin.Config.Test
{
	[TestFixture]
	public class ConfigStorageFixture
	{
		[Test]
		public void LoadAddinConfig()
		{
			string fileName = Environment.GetEnvironmentVariable("ALLUSERSPROFILE") + @"\TortoiseSVNAddin\AddinConfig.xml";
			AddinConfig config = new AddinConfig();

			var xfs = MockRepository.GenerateStub<XmlFileStorage>();
			xfs.Expect(x => x.ReadObjectFromFile<AddinConfig>(fileName)).Return(config);

			ConfigStorage cs = new ConfigStorage(xfs);
			AddinConfig retConfig = cs.LoadAddinConfig();

			Assert.AreEqual(config, retConfig);
		}

		[Test]
		public void StoreAddinConfig()
		{
			string fileName = Environment.GetEnvironmentVariable("ALLUSERSPROFILE") + @"\TortoiseSVNAddin\AddinConfig.xml";
			AddinConfig config = new AddinConfig();

			var xfs = MockRepository.GenerateMock<XmlFileStorage>();
			xfs.Expect(x => x.WirteObjectToFile(config, fileName));

			ConfigStorage cs = new ConfigStorage(xfs);
			cs.StoreAddinConfig(config);

			xfs.VerifyAllExpectations();
		}
	}
}
